package com.yonyou.isv.demo.openapi.api.message;

import com.yonyou.isv.demo.openapi.api.*;
import com.yonyou.isv.demo.openapi.base.module.reponse.ApiDataArrayResponse;
import com.yonyou.isv.demo.openapi.base.module.reponse.ApiDataStringResponse;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 代办
 */
@Component
public class TodoApi extends BaseOpenApi {

    /**
     * 获取待办条目
     * @param params
     * @return
     */
    public List<Map<String, Object>> items(Map<String, String> header, Map<String, Object> params) {
        ApiDataArrayResponse apiDataResponse =  postForEntity(OpenApiURL.TODO_ITEMS,header,params, ApiDataArrayResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 标记待办事件为已处理
     * @param params
     * @return
     */
    public String done(Map<String, Object> params) {
        ApiDataStringResponse apiDataResponse =  postForEntity(OpenApiURL.TODO_DONE,params, ApiDataStringResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 创建代办事件
     * @param params
     * @return
     */
    public String todo(Map<String, Object> params) {
        ApiDataStringResponse apiDataResponse =  postForEntity(OpenApiURL.TODO_TODO,params, ApiDataStringResponse.class);
        return getData(apiDataResponse);
    }

    /**
     *删除待办事件
     * @param params
     * @return
     */
    public String revocation(Map<String, Object> params) {
        ApiDataStringResponse apiDataResponse =  postForEntity(OpenApiURL.TODO_REVOCATION,params, ApiDataStringResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 标记待办为已读状态
     * @param params
     * @return
     */
    public String read(Map<String, Object> params) {
        ApiDataStringResponse apiDataResponse =  postForEntity(OpenApiURL.TODO_READ,params, ApiDataStringResponse.class);
        return getData(apiDataResponse);
    }

}
